#include "Vector.h"
#include <math.h>

// Create a Vector - :)
Vector::Vector(float x_, float y_, float z_):x (x_), y(y_), z(z_)
{    
}

// delete a Vector
Vector::~Vector()
{    
}

Vector Vector::operator+(const Vector &v)
{
    return Vector(x + v.x, y + v.y, z + v.z);
}

Vector Vector::operator-()
{
    return Vector(-x, -y, -z);
}


Vector Vector::operator*(const float f)
{
    return Vector(x * f, y * f, z * f);
}

// Vector cross
Vector Vector::operator*(const Vector &v)
{
    return Vector(y * v.z - v.y * z, z * v.x - x * v.z, x * v.y - y * v.z);
}

Vector &Vector::operator*=(const float f)
{
    x *= f;
    y *= f;
    z *= f;
    return *this;
}

// Cross a vector
Vector &Vector::operator*=(const Vector &v)
{
    *this = *this * v;
    return *this;
}

// Add to a vector
Vector &Vector::operator+=(const Vector &v)
{
    x += v.x;
    y += v.y;
    z += v.z;
    return *this;
}

// Mutiplication between Matrix and Vector.
Vector operator*(const Matrix &matrix, const Vector &vector)
{
    return Vector(matrix.value[0] * vector.x + matrix.value[1] * vector.y + matrix.value[2] * vector.z,
                  matrix.value[4] * vector.x + matrix.value[5] * vector.y + matrix.value[6] * vector.z,
                  matrix.value[8] * vector.x + matrix.value[9] * vector.y + matrix.value[10] * vector.z);
}